﻿
Namespace Facades

    <EditableZone(IsFacade:=True)> _
    Public Class ColumnBarChartFacade
        Inherits XamChartFacade

        Private _StackMode As ColumnBarChartStackMode
        Private _Orientation As ColumnBarChartOrientation
        Dim _Label As String

        
        <EditableProperty(Group:="Visual")> _
        Public Property Orientation As ColumnBarChartOrientation
            Get
                Return Me._Orientation
            End Get
            Set(ByVal value As ColumnBarChartOrientation)
                Me._Orientation = value
                UpdateChartType()
            End Set
        End Property
        <EditableProperty(Group:="Visual")> _
         Public Property StackMode As ColumnBarChartStackMode
            Get
                Return Me._StackMode
            End Get
            Set(ByVal value As ColumnBarChartStackMode)
                Me._StackMode = value
                UpdateChartType()
            End Set
        End Property

        <EditableProperty(Group:="Visual")> _
         Public Property Label As String
            Get
                Return _Label
            End Get
            Set(ByVal value As String)
                _Label = value

                For Each s In brother.Series
                    Dim ff = New SeriesFacade(s)
                    ff.ValueLabel = _Label
                Next
            End Set
        End Property

        'Comment faire une barre d'outil avec tous les types de graphesclique gauche affiche une zone avec les differents choix possibles mais visuel
        ' le 
        Private Sub UpdateChartType()
            For Each s In brother.Series
                Select Case Orientation
                    Case ColumnBarChartOrientation.Bar
                        Select Case StackMode
                            Case ColumnBarChartStackMode.None
                                s.ChartType = Infragistics.Windows.Chart.ChartType.Bar
                            Case ColumnBarChartStackMode.Normal
                                s.ChartType = Infragistics.Windows.Chart.ChartType.StackedBar
                            Case ColumnBarChartStackMode.Stacked100
                                s.ChartType = Infragistics.Windows.Chart.ChartType.Stacked100Bar

                        End Select

                    Case ColumnBarChartOrientation.Column
                        Select Case StackMode
                            Case ColumnBarChartStackMode.None
                                s.ChartType = Infragistics.Windows.Chart.ChartType.Column
                            Case ColumnBarChartStackMode.Normal
                                s.ChartType = Infragistics.Windows.Chart.ChartType.StackedColumn
                            Case ColumnBarChartStackMode.Stacked100
                                s.ChartType = Infragistics.Windows.Chart.ChartType.Stacked100Column

                        End Select

                End Select
            Next
        End Sub

        Private Class SS
            Inherits SeriesFacade

            Public Sub New(ByVal brother As Infragistics.Windows.Chart.Series)
                MyBase.New(brother)
            End Sub


            Public Overrides Property ValueX As String
                Get
                    Return MyBase.ValueX
                End Get
                Set(ByVal value As String)
                    MyBase.ValueX = value

                    brother.DataMapping = "Label=" & ValueX & ";Value=" & ValueY
                End Set
            End Property

            Public Overrides Property ValueY As String
                Get
                    Return MyBase.ValueY
                End Get
                Set(ByVal value As String)
                    MyBase.ValueY = value

                    brother.DataMapping = "Label=" & ValueX & ";Value=" & ValueY
                End Set
            End Property
        End Class
    End Class

    Public Enum ColumnBarChartOrientation
        [Default] = 1
        Column = 1
        Bar = 2
    End Enum

    Public Enum ColumnBarChartStackMode
        [Default] = 1
        None = 1
        Normal = 2
        Stacked100 = 3
    End Enum
End Namespace
